package com.erp.erp_mask.controller;

import com.erp.erp_mask.mapper.THouseMapper;
import com.erp.erp_mask.mapper.TPartwareMapper;
import com.erp.erp_mask.mapper.TWarehouseMapper;
import com.erp.erp_mask.pojo.THouse;
import com.erp.erp_mask.pojo.TWarehouse;
import com.erp.erp_mask.service.TPartwareService;
import com.erp.erp_mask.service.TProentrepotService;
import com.erp.erp_mask.vo.Result;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.beans.Transient;

/**
 * @BelongsProject: erp
 * @BelongsPackage: com.erp.erp_mask.controller
 * @Author: wang
 * @CreateTime: 2024-06-07  10:51
 * @Description: TODO
 * @Version: 1.0
 * @effect:
 */
@RestController
@RequestMapping("/pandian")
public class TWarehouseController {
    @Resource
    public TWarehouseMapper tWarehouseMapper;
    @Resource
    public TPartwareService tPartwareService;
    @Resource
    public TProentrepotService tProentrepotService;
    @Resource
    public THouseMapper tHouseMapper;
    @GetMapping("/index")
    public ModelAndView index(){
        return new ModelAndView("/pan/warehouseCheck");
    }
    @GetMapping("/search")
    public Result search(Integer a){
        if (a==1){
            return Result.success(tPartwareService.list());
        }else{
            return Result.success(tProentrepotService.list());
        }
    }
    @PostMapping("/addlist")
    @Transient
    public Result add(@RequestBody TWarehouse tWarehouse){
        try{
            tWarehouseMapper.add(tWarehouse);
            tHouseMapper.addlist(tWarehouse);
            System.out.println("成功@!");
            return Result.success("盘点计划提交成功!");
        }catch (Exception e){
            return Result.fail("盘点计划提交失败!");
        }
    }
}
